import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class JDBCDemo {
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		
		Class.forName("com.mysql.jdbc.Driver");
		String url = "jdbc:mysql://localhost:3306/jdbc";
		String user = "root";
		String password = "root";
		Connection conn = DriverManager.getConnection(url,user,password);
		
		Statement stmt = conn.createStatement();
		
		String sql = "SELECT * FROM Userdetail WHERE sex ='1'";
		
		ResultSet rs= stmt.executeQuery(sql);
		
		while(rs.next()){
			int id = rs.getInt(1);
			String name = rs.getString(2);
			String pwd = rs.getString(3);
			System.out.println(id +"\t"+name+"\t"+pwd);
			
		}
		
		rs.close();
		stmt.close();
		conn.close();
		
	}

}
